<?php
namespace app\admin\controller;
use think\Db;
use think\Request;
use think\Session;
class Set  extends Common
{
        public function index(){
			$info=website();//调用基本设置
			$this->view->assign('info', $info);//渲染到模板
            return $this->view->fetch();
        }
		public function setsave()
    	{
			$datas=input('data');//获取json数据
	        $datas=json_decode($datas,true);//转成数组

	        //sns按钮转成1和0
	        if($datas['sns']=='on'){
	        	$datas['sns']='1';
	        }else{
	        	$datas['sns']='0';
	        }

	        //保存数据
	        $config=Db::name('config');
	        foreach ($datas as $k => $v) {
	        	$save['value']=$v;
	        	$config->where('name',$k)->update($save);
	        }

	        $user=SESSION::get('cmuser');
            $log="$user edit set ";
            set_log($user,$log);

	        //返回成功
	        return '1';
    	}
    	public function ico()
    	{
    		$website=website();
    		$info=explode('|',$website['ico_user']);
    		$this->view->assign('info', $info);//渲染到模板
    		return $this->view->fetch();
    	}
}
